<?php
/**
 * Created by PhpStorm.
 * User: aron
 * Date: 2019/5/8
 * Time: 10:15 AM
 */

class Person
{
    /*声明为protected类型的属性，子类可以访问*/
    protected $name;/*姓名*/
    protected $age;/*年龄*/

    /**
     * Person constructor.
     * @param $name
     * @param $age
     */
    public function __construct($name, $age)
    {
        $this->name = $name;
        $this->age = $age;
    }


}

/**
 * Class Student
 * 类的继承
 */
class Student extends  Person {
    private $school;/*学校*/

    /**
     * Student constructor.
     * @param $name
     * @param $age
     * @param $school
     */
    public function __construct($name, $age, $school)
    {
        // 调用父类的构造方法
        parent::__construct($name, $age);
        $this->school = $school;
    }

    public function __toString()
    {
        return "Student (name=> $this->name, age=> $this->age, school=> $this->school)";
    }


}

$stu = new Student("xm", 12, "pnyz");
echo $stu;
